<template>
  <div class="footer">
    <div
      class="footer-item"
      :class="{ selected: selectIndex == index }"
      v-for="(item, index) in list"
      :key="index"
      @click="jump(item.path, index)"
    >
      <img
        :src="
          selectIndex == index
            ? qiniu + item.imgUrl + '_selected.png'
            : qiniu + item.imgUrl + '.png'
        "
      />

      <p>{{ item.name }}</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      qiniu: "http://qhps40fk6.hn-bkt.clouddn.com/",
      list: [
        {
          name: "首页",
          path: "/",
          imgUrl: "icon_home",
        },
        {
          name: "全系产品",
          path: "/product",
          imgUrl: "icon_product",
        },
        {
          name: "技术伙伴",
          path: "/friend",
          imgUrl: "icon_friend",
        },
        {
          name: "关于我们",
          path: "/about",
          imgUrl: "icon_about",
        },
        {
          name: "个人中心",
          path: "/my",
          imgUrl: "icon_my",
        },
      ],
      selectIndex: 0,
    };
  },
  methods: {
    jump(path, index) {
      this.$router.push(`${path}`);
      this.selectIndex = index;
    },
  },
};
</script>

<style lang="scss" scoped>
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1.493333rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  border-top: 1px solid rgb(226, 223, 223);
  z-index: 999;
  .footer-item {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    font-size: 0.266667rem;
    color: #9a9a9a;
    img {
      width: 0.533333rem;
    }
    p {
      padding-top: 0.286667rem;
    }
  }
  .selected {
    color: #c2272e;
  }
}
</style>